import { getAction, deleteAction, putAction, postAction, httpAction } from '@/api/manage'
import Vue from 'vue'
import { UI_CACHE_DB_DICT_DATA } from '@/store/mutation-types'
import { axios } from '@/utils/request'
import { serviceApi } from '@/api/common.js'
/**
 * 公共接口
 */
export const api = {

}

/**
 * 登录
 * @param parameter
 * @returns {*}
 */
export const login = params => postAction(serviceApi.auth + '/login', params);

/**
 * 手机登录
 * @param {*} params
 * @returns
 */
export const phoneLogin = params => postAction(serviceApi.auth + '/phone-login', params);

/**
* 登出
* @param parameter
* @returns {*}
*/
export const logout = token => {
  return axios({
    url: serviceApi.auth + '/logout',
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
      'X-Access-Token': token
    }
  })
}

/**
 * Cas 验证登录
 * @param {*} params
 * @returns
 */
export const casValidateLogin = params => getAction(serviceApi.auth + '/sso/cas/client/validate-login', params);

/**
 * 注册
 * @param {*} params
 * @returns
 */
export const register = params => postAction(serviceApi.auth + '/users/register', params);

/**
 * 获取验证码
 * @param {*} params
 * @returns
 */
export const getCaptcha = (key, params) => {
  return getAction(serviceApi.auth + `/captcha/${key}`, params);
}

/**
 * 验证-验证码
 * @param {*} params
 * @returns
 */
export const checkCaptcha = params => postAction(serviceApi.auth + '/check-captcha', params);

/**
 * 短信验证
 * @param {*} params
 * @returns
 */
export const sendSms = params => postAction(serviceApi.auth + '/send-sms', params);

/**
 * 获取用户信息
 * @param {*} params
 * @returns
 */
export const getSysUser = params => getAction(serviceApi.auth + '/users/phone-name', params);

/**
 * 验证用户是否存在
 * @param {*} params
 * @returns
 */
export const checkOnlyUser = params => getAction(serviceApi.auth + '/users/only-user', params)

/**
 * 获取租户选择列表，登录后如果存在多个租户需让用户选择进入哪个租户
 * @param {*} params {ids:*,*}以','分割
 * @returns
 */
export const queryTenantList = params => getAction(serviceApi.auth + '/tenants', params)

/**
 * 手机验证
 * @param {*} params
 * @returns
 */
export const phoneVerification = params => postAction(serviceApi.auth + '/users/phone-verification', params)

/**
 * todo 需修改为POST
 * 用户修改密码
 * @param {*} params
 * @returns
 */
export const changePassword = params => getAction(serviceApi.auth + '/users/password-change', params)

/**
 * 修改密码
 * 用户修改密码
 * @param {*} params
 * @returns
 */
export const updatePassword = params => putAction(serviceApi.auth + '/users/password-update', params)
